<?php
/**
 * Created by PhpStorm.
 * User: 17628
 * Date: 2021-11-22
 * Time: 16:37
 */

namespace app\api\controller;


use app\admin\model\Personal;
use app\common\controller\Api;
use app\admin\model\Module;
use think\Env;

class Mine extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    //我的页面
    //个人信息展示
    public function pim()
    {
        $model = new Personal();
        $list = $model
            ->field('id,image,nikename')
            ->find($this->auth->id);
        $list = addWebSiteUrl($list, ['image']);
        return sucessMsg('200', '获取成功', $list);
    }

    //模块名
    public function index()
    {
        $model = new Module();
        //我的订单模块名
        $list = $model
            ->where('type', 1)
            ->field('id,name,image')
            ->select();
        foreach ($list as $v) {
            $v['image'] = Env::get('app.yuming') . $v['image'];
        }
        //我的页面其他模块名
        $list1 = $model
            ->where('type', 2)
            ->field('id,name,image')
            ->select();
        foreach ($list1 as $v) {
            $v['image'] = Env::get('app.yuming') . $v['image'];
        }
        return sucessMsg('200', '获取成功', ['list' => $list, 'list1' => $list1]);
    }
}